package com.demo2do.fms.entity.authority;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.demo2do.core.format.PersistentFormat;

/**
 * 角色
 * 
 * @author Ysy
 *
 */
@Entity
@Table(name = "FMS_ROLE")
@PersistentFormat
public class Role {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;

    /** 角色标识 */
    private String code;
    
    /** 角色名称  */
    private String name;
    
    /** 角色描述  */
    private String description;
    
    /** 所属模板  */
    @Enumerated(EnumType.STRING)
    @Column(name = "ROLE_TEMPLATE")
    private RoleTemplate template;
    
    /** 是否可修改  */
    @Column(name = "is_editable")
    private Boolean editable;

    /** 创建时间 */
    private Date createTime;
    
    /** 最后更新时间  */
    private Date lastModifyTime;
    
    /** 是否启用  */
    @Column(name = "IS_DISABLED")
    private Boolean disabled;
    
    /**
     * the default constructor
     */
    public Role() {
    }
    
    /**
     * initialize
     * 
     * @param now
     * @return
     */
    public Role initialize() {
        this.editable = true;
        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.disabled = false;
        return this;
    }
    
    /**
     * @return
     */
    public Role operate() {
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @return
     */
    public Role disable() {
        this.disabled = true;
        this.lastModifyTime = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @return the template
     */
    public RoleTemplate getTemplate() {
        return template;
    }

    /**
     * @return the editable
     */
    public Boolean getEditable() {
        return editable;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @param template the template to set
     */
    public void setTemplate(RoleTemplate template) {
        this.template = template;
    }

    /**
     * @param editable the editable to set
     */
    public void setEditable(Boolean editable) {
        this.editable = editable;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }
    
}
